home *** CD-ROM | disk | FTP | other *** search
- package com.ibm.xml.dom;
-
- import org.w3c.dom.Attr;
- import org.w3c.dom.DOMException;
- import org.w3c.dom.Element;
- import org.w3c.dom.NamedNodeMap;
- import org.w3c.dom.Node;
- import org.w3c.dom.NodeList;
- import org.w3c.dom.Text;
-
- public class ElementImpl extends NodeImpl implements Element {
- static final long serialVersionUID = -7202454486126245907L;
- protected NamedNodeMapImpl attributes;
-
- public ElementImpl(DocumentImpl var1, String var2) {
- super(var1, var2, (String)null);
- super.syncData = true;
- }
-
- public short getNodeType() {
- return 1;
- }
-
- public String getNodeValue() {
- return null;
- }
-
- public void setNodeValue(String var1) throws DOMException {
- throw new DOMExceptionImpl((short)7, (String)null);
- }
-
- public NamedNodeMap getAttributes() {
- if (super.syncData) {
- this.synchronizeData();
- }
-
- return this.attributes;
- }
-
- public Node cloneNode(boolean var1) {
- if (super.syncData) {
- this.synchronizeData();
- }
-
- ElementImpl var2 = (ElementImpl)super.cloneNode(var1);
- var2.attributes = this.attributes.cloneMap();
- return var2;
- }
-
- public String getValue() {
- return null;
- }
-
- public String getAttribute(String var1) {
- if (super.syncData) {
- this.synchronizeData();
- }
-
- Attr var2 = (Attr)this.attributes.getNamedItem(var1);
- return var2 == null ? "" : var2.getValue();
- }
-
- public Attr getAttributeNode(String var1) {
- if (super.syncData) {
- this.synchronizeData();
- }
-
- return (Attr)this.attributes.getNamedItem(var1);
- }
-
- public NodeList getElementsByTagName(String var1) {
- return new DeepNodeListImpl(this, var1);
- }
-
- public String getTagName() {
- if (super.syncData) {
- this.synchronizeData();
- }
-
- return super.name;
- }
-
- public void normalize() {
- Node var2;
- for(Node var1 = ((NodeImpl)this).getFirstChild(); var1 != null; var1 = var2) {
- var2 = var1.getNextSibling();
- if (var2 != null && var1.getNodeType() == 3 && var2.getNodeType() == 3) {
- ((Text)var1).appendData(var2.getNodeValue());
- ((NodeImpl)this).removeChild(var2);
- var2 = var1;
- } else if (var1.getNodeType() == 1) {
- ((Element)var1).normalize();
- }
- }
-
- }
-
- public void removeAttribute(String var1) {
- if (super.readOnly) {
- throw new DOMExceptionImpl((short)7, (String)null);
- } else {
- if (super.syncData) {
- this.synchronizeData();
- }
-
- AttrImpl var2 = (AttrImpl)this.attributes.getNamedItem(var1);
- if (var2 != null) {
- var2.owned = false;
- this.attributes.removeNamedItem(var1);
- }
-
- }
- }
-
- public Attr removeAttributeNode(Attr var1) throws DOMException {
- if (super.readOnly) {
- throw new DOMExceptionImpl((short)7, (String)null);
- } else {
- if (super.syncData) {
- this.synchronizeData();
- }
-
- AttrImpl var2 = (AttrImpl)this.attributes.getNamedItem(var1.getName());
- if (var2 == var1) {
- this.attributes.removeNamedItem(var1.getName());
- var2.owned = false;
- return var2;
- } else {
- throw new DOMExceptionImpl((short)8, (String)null);
- }
- }
- }
-
- public void setAttribute(String var1, String var2) {
- if (super.readOnly) {
- throw new DOMExceptionImpl((short)7, (String)null);
- } else {
- if (super.syncData) {
- this.synchronizeData();
- }
-
- AttrImpl var3 = (AttrImpl)((NodeImpl)this).getOwnerDocument().createAttribute(var1);
- var3.setNodeValue(var2);
- this.attributes.setNamedItem(var3);
- var3.owned = true;
- }
- }
-
- public Attr setAttributeNode(Attr var1) throws DOMException {
- if (super.readOnly) {
- throw new DOMExceptionImpl((short)7, (String)null);
- } else {
- if (super.syncData) {
- this.synchronizeData();
- }
-
- if (!(var1 instanceof AttrImpl)) {
- throw new DOMExceptionImpl((short)4, (String)null);
- } else {
- AttrImpl var2 = (AttrImpl)var1;
- AttrImpl var3 = (AttrImpl)this.attributes.getNamedItem(var1.getName());
- this.attributes.setNamedItem(var2);
- var2.owned = true;
- return var3;
- }
- }
- }
-
- public void setReadOnly(boolean var1, boolean var2) {
- super.setReadOnly(var1, var2);
- if (super.syncChildren) {
- ((NodeImpl)this).synchronizeChildren();
- }
-
- this.attributes.setReadOnly(var1, true);
- }
-
- protected void synchronizeData() {
- super.syncData = false;
- this.setupDefaultAttributes();
- }
-
- protected void setupDefaultAttributes() {
- NamedNodeMapImpl var1 = null;
- DocumentTypeImpl var2 = (DocumentTypeImpl)super.ownerDocument.getDoctype();
- if (var2 != null) {
- ElementDefinitionImpl var3 = (ElementDefinitionImpl)var2.getElements().getNamedItem(((NodeImpl)this).getNodeName());
- if (var3 != null) {
- var1 = (NamedNodeMapImpl)var3.getAttributes();
- }
- }
-
- this.attributes = new NamedNodeMapImpl(this, var1);
- }
- }
-